//
//  UIView+ViewController.m
//  CarSource
//
//  Created by caohaifeng on 4/2/16.
//  Copyright © 2016 caohaifeng. All rights reserved.
//

#import "UIView+ViewController.h"

@implementation UIView (ViewController)


- (UINavigationController *)navigationController {
    UIResponder *next = self.nextResponder;
    while (next != nil) {
        if ([[next class] isSubclassOfClass:[UINavigationController class]]) {
            return (UINavigationController *)next;
        }
        next = next.nextResponder;
    }
    return nil;
}

- (UIViewController *)viewController {
    UIResponder *next = self.nextResponder;
    while (next != nil) {
        if ([[next class] isSubclassOfClass:[UIViewController class]]) {
            return (UIViewController *)next;
        }
        next = next.nextResponder;
    }
    return nil;
}

@end
